package org.schat;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;

/**
 * @Description
 * @Author lsh
 * @Date 2020/3/18 13:14
 **/
public class SandSculptureName {
    private static String[] lastNameArr = {"张","李","王"};
    private static String[] middleNameArr =  {"小","二"};
    private static String[] fristNameArr ={"明","伟","花","红","驴","鱼"};
    private static String[] hahahahaArr = {"二狗","狗剩"};

    public static String generator(){
        SecureRandom random = null;
        try {
            random = SecureRandom.getInstance("SHA1PRNG");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        if(random != null){
            String lastName = lastNameArr[random.nextInt(lastNameArr.length)];
            if(new Random().nextInt(20) == 2){
                //拥有二十分之一的几率抽取到沙雕昵称
                return lastName + hahahahaArr[random.nextInt(hahahahaArr.length)];
            }else{
                String middleName = middleNameArr[random.nextInt(middleNameArr.length)];
                String firstname = fristNameArr[random.nextInt(fristNameArr.length)];
                return lastName + middleName + firstname;
            }

        }
        return "未知错误！";
    }

    public static void main(String[] args){
        for(int i = 0;i < 10; i++){
            System.out.println(generator());
        }
    }
}
